<template>
	<div class="hospital">
		<!-- 导航区 -->
		<div class="menu">
			<div class="sticky">
				<div class="header">
					<el-icon class="el-icon"><House /></el-icon>
					<span>/ 医院信息</span>
				</div>
				<el-menu :default-active="route.path">
					<el-menu-item index="/hospital/register" @click="go">
						<el-icon><Calendar /></el-icon>
						<span>预约挂号</span>
					</el-menu-item>
					<el-menu-item index="/hospital/detail" @click="go">
						<el-icon><Document /></el-icon>
						<span>医院详情</span>
					</el-menu-item>
					<el-menu-item index="/hospital/notice" @click="go">
						<el-icon><Bell /></el-icon>
						<span>预约须知</span>
					</el-menu-item>
					<el-menu-item index="/hospital/close" @click="go">
						<el-icon><Warning /></el-icon>
						<span>停诊信息</span>
					</el-menu-item>
					<el-menu-item index="/hospital/search" @click="go">
						<el-icon><Search /></el-icon>
						<span>查询/取消</span>
					</el-menu-item>
				</el-menu>
			</div>
		</div>
		<!-- 展示区 -->
		<div class="content" v-loading="loading">
			<template v-if="hospitalDetailStore.hospitalDetail.hospital">
				<router-view></router-view>
			</template>
		</div>
	</div>
</template>

<script setup lang="ts">
import { Calendar, Document, Bell, Warning, Search, House } from '@element-plus/icons-vue';
import { useRoute, useRouter } from 'vue-router';
import { onMounted, ref } from 'vue';
import { useHospitalDetailStore } from '@/store/hospitalDetail';

const route = useRoute();
const router = useRouter();

const hospitalDetailStore = useHospitalDetailStore();

let loading = ref(false);

onMounted(() => {
	loading.value = true;

	// 获取医院数据
	hospitalDetailStore.getHospitalDetail(route.query.hoscode as string, () => {
		loading.value = false;
	});

	// 获取医院科室数据
	hospitalDetailStore.getHospitalDeparment(route.query.hoscode as string);
});

function go(obj: any) {
	router.push({
		path: obj.index,
		query: {
			hoscode: route.query.hoscode,
		},
	});
}
</script>

<style scoped lang="scss">
.hospital {
	display: flex;
	.menu {
		flex: 2;
		.sticky {
			position: sticky;
			top: 80px;
			.header {
				color: #aaa;
				font-size: 14px;
				padding-left: 22px;
				margin-bottom: 10px;
				display: flex;
				align-items: center;
				.el-icon {
					margin-right: 4px;
				}
			}
			:deep(.el-menu) {
				width: 180px;
			}
		}
	}
	.content {
		flex: 8;
	}
}
</style>
